<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="Cask Data, Inc." name="author" />
<meta content="Copyright © 2014-2018 Cask Data, Inc." name="copyright" />


    <meta name="git_release" content="6.1.1">
    <meta name="git_hash" content="05fbac36f9f7aadeb44f5728cea35136dbc243e5">
    <meta name="git_timestamp" content="2020-02-09 08:22:47 +0800">
    <title>构建和运行 CDAP 应用</title>

    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-dynamicscrollspy-4.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/cdap-jquery.mCustomScrollbar.css" type="text/css" />
    <link rel="stylesheet" href="../_static/css/abixTreeList-2.css" type="text/css" />
    <link rel="stylesheet" href="../_static/cdap-bootstrap.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '6.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>

    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="Cask Data Application Platform 6.1.1 Documentation" href="../index.html" />
    <link rel="up" title="CDAP 入门指南" href="index.html" />
    <link rel="next" title="CDAP 概述" href="../overview/index.html" />
    <link rel="prev" title="启动和停止 CDAP Sandbox" href="start-stop-cdap.html" />
    <!-- block extrahead -->
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <!-- block extrahead end -->

</head>
<body role="document">

<!-- block navbar -->
<div id="navbar" class="navbar navbar-inverse navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="row">
        <div class="navbar-header">
          <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
          <a class="navbar-brand" href="../table-of-contents/../../index.html">
            <span><img alt="CDAP logo" src="../_static/cdap_logo.svg"/></span>
          </a>

          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>

          <div class="pull-right">
            <div class="dropdown version-dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                role="button" aria-haspopup="true" aria-expanded="false">
                v 6.1.1 <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                <li><a href="//docs.cdap.io/cdap/5.1.2/en/index.html">v 5.1.2</a></li>
                <li><a href="//docs.cdap.io/cdap/4.3.4/en/index.html">v 4.3.4</a></li>
              </ul>
            </div>
          </div>
          <form class="navbar-form navbar-right navbar-search" action="../search.html" method="get">
            <div class="form-group">
              <div class="navbar-search-image material-icons"></div>
              <input type="text" name="q" class="form-control" placeholder="  Search" />
            </div>
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
          </form>

          <div class="collapse navbar-collapse nav-collapse navbar-right navbar-navigation">
            <ul class="nav navbar-nav"><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../index.html">简介</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link current" href="../table-of-contents/../../guides.html">手册</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../reference-manual/index.html">参考</a></li><li class="docsite-nav-tab-container"><a class="docsite-nav-tab-link " href="../table-of-contents/../../faqs/index.html">帮助</a></li>
            </ul>
          </div>

        </div>
      </div>
    </div>
  </div><!-- block navbar end -->
<!-- block main content -->
<div class="main-container container">
  <div class="row"><div class="col-md-2">
      <div id="sidebar" class="bs-sidenav scrollable-y-outside" role="complementary">
<!-- theme_manual: developer-manual -->
<!-- theme_manual_highlight: guides -->
<!-- sidebar_title_link: ../table-of-contents/../../guides.html -->

  <div role="note" aria-label="manuals links"><h3><a href="../table-of-contents/../../guides.html">Guides</a></h3>

    <ul class="this-page-menu">
      <li class="toctree-l1"><a href="../table-of-contents/../../user-guide/index.html" rel="nofollow">用户手册</a>
      </li>
      <li class="toctree-l1"><b><a href="../table-of-contents/../../developer-manual/index.html" rel="nofollow">开发手册</a></b>
      <nav class="pagenav">
      <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html"> 简介</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html"> 入门指南</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="sandbox/index.html">CDAP Sandbox</a><ul>
<li class="toctree-l3"><a class="reference internal" href="sandbox/zip.html">二进制 Zip 文件</a></li>
<li class="toctree-l3"><a class="reference internal" href="sandbox/zip.html#cdap-sandbox">启动和停止 CDAP Sandbox</a></li>
<li class="toctree-l3"><a class="reference internal" href="sandbox/virtual-machine.html">虚拟机镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="sandbox/docker.html">Docker 镜像</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="quick-start.html">快速入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="dev-env.html">搭建开发环境</a></li>
<li class="toctree-l2"><a class="reference internal" href="start-stop-cdap.html">启动和停止 CDAP</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">构建并运行应用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../overview/index.html"> 概述</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../overview/anatomy.html"> 大数据应用剖析</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/modes.html"> 模式和组件</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/abstractions.html"> 核心概念</a></li>
<li class="toctree-l2"><a class="reference internal" href="../overview/interfaces.html"> 编程接口</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../building-blocks/index.html"> 抽象概念</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/core.html"> Core Abstractions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/applications.html"> Applications</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/datasets/index.html"> Datasets</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/overview.html"> Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/table.html"> Table API</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/fileset.html"> FileSets</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/partitioned-fileset.html"> Partitioned FileSets</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/time-partitioned-fileset.html"> TimePartitioned FileSets</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/system-custom.html"> System and Custom Datasets</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/permissions.html"> Dataset Permissions</a></li>
<li class="toctree-l3"><a class="reference internal" href="../building-blocks/datasets/cube.html"> Cube Dataset</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/mapreduce-programs.html"> MapReduce Programs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/plugins.html"> Plugins</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/schedules.html"> Schedules</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/secure-keys.html"> Secure Keys</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/services.html"> Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/spark-programs.html"> Spark Programs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/workers.html"> Workers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/workflows.html"> Workflows</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/artifacts.html"> Artifacts</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/program-lifecycle.html"> Program Lifecycle</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/namespaces.html"> Namespaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/transaction-system.html"> Transaction System</a></li>
<li class="toctree-l2"><a class="reference internal" href="../building-blocks/transactional-messaging-system.html"> Transactional Messaging System</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../metadata/index.html"> 元数据</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../metadata/system-metadata.html"> System Metadata</a></li>
<li class="toctree-l2"><a class="reference internal" href="../metadata/discovery-lineage.html"> Discovery and Lineage</a></li>
<li class="toctree-l2"><a class="reference internal" href="../metadata/field-lineage.html"> Field Level Lineage</a></li>
<li class="toctree-l2"><a class="reference internal" href="../metadata/audit-logging.html"> Audit Logging</a></li>
<li class="toctree-l2"><a class="reference internal" href="../metadata/metadata-ui.html"> CDAP Metadata UI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../metadata/programmatic-metadata.html"> Accessing metadata programmatically</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../pipelines/index.html"> 数据流管道</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/concepts-design.html"> Concepts and Design</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/getting-started.html"> Getting Started</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/studio.html"> CDAP Studio</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/creating-pipelines.html"> Creating Pipelines</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/running-pipelines.html"> Running Pipelines</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/plugin-management.html"> Plugin Management</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/plugins/index.html"> Plugin Reference</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/actions/index.html"> Action Plugins</a><ul class="simple">
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/sources/index.html"> Source Plugins</a><ul class="simple">
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/transforms/index.html"> Transform Plugins</a><ul class="simple">
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/analytics/index.html"> Analytic Plugins</a><ul class="simple">
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/sinks/index.html"> Sink Plugins</a><ul class="simple">
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/shared-plugins/index.html"> Shared Plugins</a><ul>
<li class="toctree-l4"><a class="reference internal" href="../pipelines/plugins/shared-plugins/core.html">CoreValidator</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/plugins/post-run-plugins/index.html"> Post-run Plugins</a><ul class="simple">
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/developing-pipelines.html"> Developing Pipelines</a></li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/developing-plugins/index.html"> Developing Plugins</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/developing-plugins/plugin-basics.html">Plugin Basics</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/developing-plugins/creating-a-plugin.html">Creating a Plugin</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/developing-plugins/presentation-plugins.html">Plugin Presentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/developing-plugins/testing-plugins.html">Testing Plugins</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pipelines/developing-plugins/packaging-plugins.html">Packaging Plugins</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../pipelines/how-cdap-pipelines-work.html"> How CDAP Pipelines Work</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../cloud-runtimes/index.html"> 云平台运行</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../cloud-runtimes/concepts/index.html"> Concepts</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cloud-runtimes/provisioners/index.html"> Provisioners</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../cloud-runtimes/provisioners/gcp-dataproc.html">Google Dataproc</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cloud-runtimes/provisioners/aws-emr.html">Amazon Elastic MapReduce</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cloud-runtimes/provisioners/remote-hadoop.html">Remote Hadoop</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../cloud-runtimes/profiles/index.html"> Profiles</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../cloud-runtimes/profiles/creating-profiles.html">Creating Profiles</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cloud-runtimes/profiles/assigning-profiles.html">Assigning Profiles</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cloud-runtimes/profiles/admin-controls.html">Admin Controls</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../cloud-runtimes/example/index.html"> Example</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../security/index.html"> 安全</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../security/client-authentication.html">Client Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/cdap-authentication-clients-java.html">CDAP Authentication Client for Java</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/cdap-authentication-clients-python.html">CDAP Authentication Client for Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/custom-authentication.html">Custom Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="../security/authorization-extensions.html">Authorization Extensions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html"> 测试和调试</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../testing/testing.html"> Testing a CDAP Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/debugging.html"> Debugging</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/troubleshooting.html"> Troubleshooting</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ingesting-tools/index.html"> 数据融合</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../ingesting-tools/cdap-stream-clients-java.html">CDAP Stream Client for Java</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ingesting-tools/cdap-stream-clients-python.html">CDAP Stream Client for Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ingesting-tools/cdap-stream-clients-ruby.html">CDAP Stream Client for Ruby</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ingesting-tools/cdap-flume.html">CDAP Flume</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../data-exploration/index.html"> 数据探索</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../data-exploration/filesets.html"> Fileset Exploration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../data-exploration/tables.html"> Table Exploration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../data-exploration/object-mapped-tables.html"> ObjectMappedTable Exploration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../data-exploration/custom-datasets.html"> Custom Dataset Exploration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../data-exploration/hive-execution-engines.html"> Hive Execution Engines</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/index.html"> 高级主题</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../advanced/application-logback.html"> Application Logback</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/best-practices.html"> Best Practices</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/class-loading.html"> Class Loading</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/configuring-resources.html"> Configuring Program Resources</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/program-retry-policies.html"> Program Retry Policies</a></li>
</ul>
</li>
</ul>
</nav>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../admin-manual/index.html" rel="nofollow">管理手册</a>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../integrations/index.html" rel="nofollow">集成手册</a>
      </li>
      <li class="toctree-l1"><a href="../table-of-contents/../../examples-manual/index.html" rel="nofollow">最佳实践</a>
      </li>
    </ul>
  </div></div>
    </div><div class="col-md-8 content" id="main-content">
    
  <div class="section" id="cdap">
<span id="cdap-building-running"></span><h1>构建和运行 CDAP 应用<a class="headerlink" href="#cdap" title="Permalink to this headline">🔗</a></h1>
<p>在下面的例子中, 我们称 CDAP Sandbox 为 <em>CDAP</em>, 称运行在它上面的样例代码为一个 <em>应用</em>.
我们假设您正在 <em>default</em> <a class="reference internal" href="../building-blocks/namespaces.html#namespaces"><span class="std std-ref">namespace</span></a> 中运行你的应用;
如果不是, 你需要相应调整命令. 例如, 在一个这样的 URL 中:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">http://localhost:11015/v3/namespaces/default/apps...</span>
</pre></div>
</div>
<p>如果要使用名字空间 <em>my_namespace</em>, 你需要将 <code class="docutils literal notranslate"><span class="pre">default</span></code> 替换为 <code class="docutils literal notranslate"><span class="pre">my_namespace</span></code>:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">http://localhost:11015/v3/namespaces/my_namespace/apps...</span>
</pre></div>
</div>
<div class="section" id="cli-curl-cdap-sandbox-bin">
<h2>存取 CLI, curl, 和 CDAP Sandbox bin<a class="headerlink" href="#cli-curl-cdap-sandbox-bin" title="Permalink to this headline">🔗</a></h2>
<ul>
<li><p class="first">为了简化, 在下面的命令中, 我们使用 <code class="docutils literal notranslate"><span class="pre">cdap</span> <span class="pre">cli</span></code> 表示 CDAP 命令行接口.
取代实际路径 <code class="docutils literal notranslate"><span class="pre">./&lt;CDAP-HOME&gt;/bin/cdap</span> <span class="pre">cli</span></code>,
或 <code class="docutils literal notranslate"><span class="pre">&lt;CDAP-HOME&gt;\bin\cdap.bat</span> <span class="pre">cli</span></code> (Windows).</p>
</li>
<li><p class="first">一个 Windows 版本的 <code class="docutils literal notranslate"><span class="pre">curl</span></code> 程序包含在 CDAP Sandbox 中 (路径
<code class="docutils literal notranslate"><span class="pre">libexec\bin\curl.exe</span></code>); 请使用它代替例子中的 <code class="docutils literal notranslate"><span class="pre">curl</span></code>.</p>
</li>
<li><p class="first">如果你把 CDAP Sandbox <code class="docutils literal notranslate"><span class="pre">bin</span></code> 目录添加到搜索路径, 则可以简化命令.
从 <code class="docutils literal notranslate"><span class="pre">&lt;CDAP-HOME&gt;</span></code> 目录, 输入:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral30() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral30 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral30", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral30" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span><span class="si">${</span><span class="nv">PATH</span><span class="si">}</span>:<span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>/bin
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> <span class="nb">set</span> <span class="nv">path</span><span class="o">=</span>%PATH%<span class="p">;</span>%CD%<span class="se">\b</span>in<span class="p">;</span>%CD%<span class="se">\l</span>ibexec<span class="se">\b</span>in
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<p>Windows 上的路径我们还包含了 CDAP Sandbox 中的
Windows 版本命令的路径, 例如 <code class="docutils literal notranslate"><span class="pre">curl</span></code> 命令.</p>
</li>
</ul>
<p><strong>Note:</strong> 当前在 Microsoft Windows 上使用 CDAP 本地 Sandbox
脚本时, 如果 <code class="docutils literal notranslate"><span class="pre">CDAP_HOME</span></code> 定义为带空格的路径会有问题. 在该问题解决之前,
请不要对 <code class="docutils literal notranslate"><span class="pre">CDAP_HOME.</span></code> 使用带空格的路径</p>
</div>
<div class="section" id="cdap-building-running-example">
<span id="id1"></span><h2>构建样例应用<a class="headerlink" href="#cdap-building-running-example" title="Permalink to this headline">🔗</a></h2>
<p>从样例工程根目录 (例如 <code class="docutils literal notranslate"><span class="pre">examples/&lt;example-dir&gt;</span></code>), 使用
<a class="reference external" href="http://maven.apache.org">Apache Maven</a> 命令构建样例应用:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral31() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral31 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral31", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral31" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> mvn clean package
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> mvn clean package
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<p>构建而不运行测试, 使用:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral32() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral32 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral32", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral32" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> mvn clean package -DskipTests
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> mvn clean package -DskipTests
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<p>要构建全部样例应用, 请切换到样例主目录并运行 Maven 命令:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral33() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral33 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral33", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral33" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nb">cd</span> &lt;CDAP-HOME&gt;/examples
<span class="gp">$ </span><span class="copyable-text">mvn clean package -DskipTests</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> <span class="nb">cd</span> &lt;CDAP-HOME&gt;<span class="se">\e</span>xamples
<span class="gp">&gt; </span><span class="copyable-text">mvn clean package -DskipTests</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
</div>
<div class="section" id="cdap-building-running-starting">
<span id="id2"></span><h2>启动 CDAP<a class="headerlink" href="#cdap-building-running-starting" title="Permalink to this headline">🔗</a></h2>
<p>在运行一个样例应用之前, 请检查确保 CDAP 实例正在运行并且可用; 如果没有,
请按这里给出的步骤操作 <a class="reference internal" href="start-stop-cdap.html#start-stop-cdap"><span class="std std-ref">启动和停止 CDAP Sandbox</span></a>.</p>
<p>如果你能够通过浏览地址 <a class="reference external" href="http://localhost:11011/oldcdap/ns/default/">http://localhost:11011/</a> 访问 CDAP UI,
说明 CDAP 正在运行.</p>
</div>
<div class="section" id="cdap-building-running-deploying">
<span id="id3"></span><h2>发布应用<a class="headerlink" href="#cdap-building-running-deploying" title="Permalink to this headline">🔗</a></h2>
<p>一旦 CDAP 已启动, 我们有多种方法使用样例 JAR 发布一个应用:</p>
<ul>
<li><p class="first">使用 CDAP UI 上的绿色 “+” 按钮上传应用 JAR 文件</p>
</li>
<li><p class="first">使用 <span class="xref std std-ref">命令行界面 (CLI)</span>:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral34() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral34 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral34", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral34" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> cdap cli load artifact examples/&lt;example-directory&gt;/target/&lt;example&gt;-6.1.1.jar
<span class="go">Successfully added artifact with name &#39;&lt;example&gt;&#39;</span>

<span class="gp">$ </span><span class="copyable-text">cdap cli create app &lt;app name&gt; &lt;example&gt; <span class="m">6</span>.1.1 user</span>
<span class="go">Successfully created application</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> cdap cli load artifact examples<span class="se">\&lt;</span>example-directory&gt;<span class="se">\t</span>arget<span class="se">\&lt;</span>example&gt;-6.1.1.jar
<span class="go">Successfully added artifact with name &#39;&lt;example&gt;&#39;</span>

<span class="gp">&gt; </span><span class="copyable-text">cdap cli create app &lt;app name&gt; &lt;example&gt; <span class="m">6</span>.1.1 user</span>
<span class="go">Successfully created application</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<p>在 Windows 上使用 <code class="docutils literal notranslate"><span class="pre">bin\cdap.bat</span> <span class="pre">cli</span></code> 脚本运行 CLI 命令.</p>
</li>
<li><p class="first">使用像 <code class="docutils literal notranslate"><span class="pre">curl</span></code> 这样的应用(一个 Windows 版本程序已经包含在 CDAP Sandbox 中的路径
<code class="docutils literal notranslate"><span class="pre">libexec\bin\curl.exe</span></code> 下):</p>

<script type="text/javascript">

  $(function tabbedparsedliteral35() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral35 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral35", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral35" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> curl -w<span class="s2">&quot;\n&quot;</span> localhost:11015/v3/namespaces/default/artifacts/&lt;example&gt; <span class="se">\</span>
  --data-binary @examples/&lt;example-directory&gt;/target/&lt;example&gt;-6.1.1.jar</span>
<span class="go">Artifact added successfully</span>

<span class="gp">$ </span><span class="copyable-text">curl -w<span class="s2">&quot;\n&quot;</span> -X PUT -H <span class="s2">&quot;Content-Type: application/json&quot;</span> localhost:11015/v3/namespaces/default/apps/&lt;app name&gt; <span class="se">\</span>
  -d <span class="s1">&#39;{ &quot;artifact&quot;: { &quot;name&quot;: &quot;&lt;example&gt;&quot;, &quot;version&quot;: &quot;6.1.1&quot;, &quot;scope&quot;: &quot;user&quot; }, &quot;config&quot;: {} }&#39;</span></span>
<span class="go">Deploy Complete</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> curl localhost:11015/v3/namespaces/default/artifacts/&lt;example&gt; ^
<span class="go">  --data-binary @examples\&lt;example-directory&gt;\target\&lt;example&gt;-6.1.1.jar</span>
<span class="go">Artifact added successfully</span>

<span class="gp">&gt; </span><span class="copyable-text">curl -X PUT -H <span class="s2">&quot;Content-Type: application/json&quot;</span> localhost:11015/v3/namespaces/default/apps/&lt;app name&gt; ^</span>
<span class="go">  -d &quot;{ \&quot;artifact\&quot;: { \&quot;name\&quot;: \&quot;&lt;example&gt;\&quot;, \&quot;version\&quot;: \&quot;6.1.1\&quot;, \&quot;scope\&quot;: \&quot;user\&quot; }, \&quot;config\&quot;: {} }&quot;</span>
<span class="go">Deploy Complete</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="section" id="cdap-building-running-starting-programs">
<span id="cdap-building-running-starting-application"></span><span id="id4"></span><h2>启动应用内的程序<a class="headerlink" href="#cdap-building-running-starting-programs" title="Permalink to this headline">🔗</a></h2>
<p>一旦一个应用已经发布, 那么有多个方法启动其中的程序:</p>
<ul>
<li><p class="first">CDAP UI.</p>
</li>
<li><p class="first">使用 <span class="xref std std-ref">命令行界面</span> 来启动应用中的一个特定程序.
(在每个 CDAP 样例中, 都提供了针对特定那个样例的 CLI 命令):</p>

<script type="text/javascript">

  $(function tabbedparsedliteral36() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral36 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral36", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral36" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> cdap cli start &lt;program-type&gt; &lt;app-id.program-id&gt;
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> cdap cli start &lt;program-type&gt; &lt;app-id.program-id&gt;
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">参数</th>
<th class="head">说明</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">&lt;program-type&gt;</span></code></td>
<td>可以为 <code class="docutils literal notranslate"><span class="pre">flow</span></code>, <code class="docutils literal notranslate"><span class="pre">mapreduce</span></code>, <code class="docutils literal notranslate"><span class="pre">service</span></code>, <code class="docutils literal notranslate"><span class="pre">spark</span></code>, <code class="docutils literal notranslate"><span class="pre">worker</span></code>, or <code class="docutils literal notranslate"><span class="pre">workflow</span></code> 中的一个</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">&lt;app-id&gt;</span></code></td>
<td>应用名称</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">&lt;program-id&gt;</span></code></td>
<td><em>flow</em>, <em>MapReduce</em>, <em>service</em>, <em>spark</em>, <em>worker</em> or <em>workflow</em> 程序的名称</td>
</tr>
</tbody>
</table>
</li>
</ul>
<ul>
<li><p class="first">使用 <span class="xref std std-ref">命令行界面</span> 一次启动应用中全部或选定类型的程序:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral37() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral37 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral37", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral37" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> start app &lt;app-id&gt; programs <span class="o">[</span>of <span class="nb">type</span> &lt;program-types&gt;<span class="o">]</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> start app &lt;app-id&gt; programs <span class="o">[</span>of <span class="nb">type</span> &lt;program-types&gt;<span class="o">]</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">参数</th>
<th class="head">说明</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">&lt;app-id&gt;</span></code></td>
<td>应用名称</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">&lt;program-types&gt;</span></code></td>
<td>可选参数. 逗号分隔的程序类型 (<code class="docutils literal notranslate"><span class="pre">flow</span></code>, <code class="docutils literal notranslate"><span class="pre">mapreduce</span></code>, <code class="docutils literal notranslate"><span class="pre">service</span></code>,
<code class="docutils literal notranslate"><span class="pre">spark</span></code>, <code class="docutils literal notranslate"><span class="pre">worker</span></code>, or <code class="docutils literal notranslate"><span class="pre">workflow</span></code>) 用来启动所有这些类型的程序;
例如, 指定 <code class="docutils literal notranslate"><span class="pre">'flow,workflow'</span></code> 将会启动应用中的所有 flows 和 workflows 程序</td>
</tr>
</tbody>
</table>
</li>
</ul>
<ul class="simple">
<li>使用生命周期 HTTP RESTful API 中的 <span class="xref std std-ref">程序生命周期</span>
来启动应用中的程序. 需要使用像 <code class="docutils literal notranslate"><span class="pre">curl</span></code> 这样的工具</li>
</ul>
</div>
<div class="section" id="cdap-building-running-stopping-program">
<span id="cdap-building-running-stopping-application"></span><span id="cdap-building-running-stopping"></span><span id="id5"></span><h2>停止应用中的程序<a class="headerlink" href="#cdap-building-running-stopping-program" title="Permalink to this headline">🔗</a></h2>
<p>一旦一个应用已经发布, 我们有多种方法来停止该应用的程序:</p>
<ul>
<li><p class="first">使用 CDAP UI.</p>
</li>
<li><p class="first">使用 <span class="xref std std-ref">命令行界面</span> 来停止应用中的指定程序:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral38() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral38 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral38", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral38" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> cdap cli stop &lt;program-type&gt; &lt;app-id.program-id&gt;
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> cdap cli stop &lt;program-type&gt; &lt;app-id.program-id&gt;
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">参数</th>
<th class="head">说明</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">&lt;program-type&gt;</span></code></td>
<td>可以为 <code class="docutils literal notranslate"><span class="pre">flow</span></code>, <code class="docutils literal notranslate"><span class="pre">mapreduce</span></code>, <code class="docutils literal notranslate"><span class="pre">service</span></code>, <code class="docutils literal notranslate"><span class="pre">spark</span></code>, <code class="docutils literal notranslate"><span class="pre">worker</span></code>, or <code class="docutils literal notranslate"><span class="pre">workflow</span></code> 中的一个</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">&lt;app-id&gt;</span></code></td>
<td>应用名称</td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">&lt;program-id&gt;</span></code></td>
<td><em>flow</em>, <em>MapReduce</em>, <em>service</em>, <em>spark</em>, <em>worker</em> or <em>workflow</em> 程序名称</td>
</tr>
</tbody>
</table>
</li>
</ul>
<ul>
<li><p class="first">使用 <span class="xref std std-ref">Command Line Interface</span> 一次停止应用中全部或选定类型的程序:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral39() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral39 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral39", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral39" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> stop app &lt;app-id&gt; programs <span class="o">[</span>of <span class="nb">type</span> &lt;program-types&gt;<span class="o">]</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> stop app &lt;app-id&gt; programs <span class="o">[</span>of <span class="nb">type</span> &lt;program-types&gt;<span class="o">]</span>
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">参数</th>
<th class="head">说明</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">&lt;app-id&gt;</span></code></td>
<td>应用名称</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">&lt;program-types&gt;</span></code></td>
<td>可选参数. 逗号分隔的程序类型 (<code class="docutils literal notranslate"><span class="pre">flow</span></code>, <code class="docutils literal notranslate"><span class="pre">mapreduce</span></code>, <code class="docutils literal notranslate"><span class="pre">service</span></code>,
<code class="docutils literal notranslate"><span class="pre">spark</span></code>, <code class="docutils literal notranslate"><span class="pre">worker</span></code>, or <code class="docutils literal notranslate"><span class="pre">workflow</span></code>) 用来停止所有这些类型的程序;
例如, 指定 <code class="docutils literal notranslate"><span class="pre">'flow,workflow'</span></code> 将会停止应用中的所有 flows 和 workflows 程序</td>
</tr>
</tbody>
</table>
</li>
</ul>
<ul class="simple">
<li>使用生命周期 HTTP RESTful API 中的 <span class="xref std std-ref">程序生命周期</span>
来停止应用中的程序. 需要使用像 <code class="docutils literal notranslate"><span class="pre">curl</span></code> 这样的工具</li>
</ul>
</div>
<div class="section" id="cdap-building-running-removing">
<span id="id6"></span><h2>移除应用<a class="headerlink" href="#cdap-building-running-removing" title="Permalink to this headline">🔗</a></h2>
<p>一旦一个应用处于 “停止” 状态—也就是它所有的程序都停止了—你可以使用 CDAP UI 移除这个应用.</p>
<p>另外, 你也可以使用命令行界面:</p>

<script type="text/javascript">

  $(function tabbedparsedliteral40() {
    var tabs = ['linux', 'windows'];
    var mapping = {'windows': 'windows', 'linux': 'linux'};
    var tabSetID = 'linux-windows';
    for (var i = 0; i < tabs.length; i++) {
      var tab = tabs[i];
      $("#tabbedparsedliteral40 .example-tab-" + tab).click(changeExampleTab(tab, mapping, "tabbedparsedliteral40", tabSetID));
    }
  });

</script>
<div id="tabbedparsedliteral40" class="tabbed-parsed-literal dependent-linux-windows">
<ul class="tabbed-parsed-literal nav-tabs">
<li class="example-tab example-tab-linux active"><a href="#">Linux</a></li>
<li class="example-tab example-tab-windows "><a href="#">Windows</a></li>
</ul>

<div class="tab-contents">

<div class="tab-pane tab-pane-linux active">
<div class="code code-tab">
<div class="highlight-console">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">$</span> cdap cli delete app &lt;app-id&gt;
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
<div class="tab-pane tab-pane-windows ">
<div class="code code-tab">
<div class="highlight-shell-session">
<!-- tabbed-parsed-literal start -->
<div class="highlight"><pre><span></span><span class="gp">&gt;</span> cdap cli delete app &lt;app-id&gt;
</pre></div>
<!-- tabbed-parsed-literal end --></div>
</div>
</div>
</div>
</div>
<p>注意: 应用创建或使用的任何 datasets 将会保留, 因为他们独立于应用.
可以使用 CDAP UI 删除 datasets, 也可以使用
<span class="xref std std-ref">HTTP Restful API</span>, <span class="xref std std-ref">Java 客户端 API</span>, 或者
<span class="xref std std-ref">命令行界面 API</span> 来删除.</p>
<p>streams 也可以使用类似地方法被截断或删除.</p>
<p>用来创建应用的构件则会保留, 因为使用同一个构件可以创建多个应用. 构件也可以使用 UI 删除, 或者使用
<span class="xref std std-ref">Http Restful API</span>,
<span class="xref std std-ref">Java 客户端 API</span>, 或者 <span class="xref std std-ref">Command Line Interface API</span> 来删除.</p>
</div>
</div>

</div>
    <div class="col-md-2">
      <div id="right-sidebar" class="bs-sidenav scrollable-y" role="complementary">
        <div id="localtoc-scrollspy">
        </div>
      </div>
    </div></div>
</div>
<!-- block main content end -->
<!-- block footer -->
<footer class="footer">
      <div class="container">
        <div class="row">
          <div class="col-md-2 footer-left"><a title="启动和停止 CDAP Sandbox" href="start-stop-cdap.html" />Previous</a></div>
          <div class="col-md-8 footer-center"><a class="footer-tab-link" href="../table-of-contents/../../reference-manual/licenses/index.html">Copyright</a> &copy; 2014-2020 Cask Data, Inc.&bull; <a class="footer-tab-link" href="//docs.cask.co/cdap/6.1.1/cdap-docs-6.1.1-web.zip" rel="nofollow">Download</a> an archive or
<a class="footer-tab-link" href="//docs.cask.co/cdap">switch the version</a> of the documentation
          </div>
          <div class="col-md-2 footer-right"><a title="CDAP 概述" href="../overview/index.html" />Next</a></div>
        </div>
      </div>
    </footer>
<!-- block footer end -->
<script type="text/javascript" src="../_static/bootstrap-3.3.6/js/bootstrap.min.js"></script><script type="text/javascript" src="../_static/js/bootstrap-sphinx.js"></script><script type="text/javascript" src="../_static/js/abixTreeList-2.js"></script><script type="text/javascript" src="../_static/js/cdap-dynamicscrollspy-4.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script><script type="text/javascript" src="../_static/js/copy-to-clipboard.js"></script><script type="text/javascript" src="../_static/js/jquery.mousewheel.min.js"></script><script type="text/javascript" src="../_static/js/jquery.mCustomScrollbar.js"></script><script type="text/javascript" src="../_static/js/js.cookie.js"></script><script type="text/javascript" src="../_static/js/tabbed-parsed-literal-0.2.js"></script><script type="text/javascript" src="../_static/js/cdap-onload-javascript.js"></script><script type="text/javascript" src="../_static/js/cdap-version-menu.js"></script>
    <script src="https://cdap.gitee.io/docs/cdap/json-versions.js"/></script>
  </body>
</html>